<div class="grid_16">
    <a href="<?php echo base_url(); ?>backend/blog/create">
        <button class="round_all but_right">
            <img src="<?php echo base_url(); ?>static/backend/images/icons/small/white/Pencil.png" width="24" height="24" alt="Pencil"/>
            <span>Viết bài mới</span>
        </button>
    </a>
</div>
<div class="box grid_16 round_all">
    <table class="display table mytable"> 
        <thead> 
            <tr> 
                <th>Tiêu đề</th>
                <th>Chuyên mục</th>
                <th>Ngày đăng</th>
                <th>Thể loại</th>
                <th>Bình luận</th> 
                <th>Trạng thái</th> 
                <th>&nbsp;</th> 
            </tr> 
        </thead> 
        <tbody>
        <?php
            if (sizeof($arrData) > 0)
            {
                foreach ($arrData as $idex => $blog)
                {
                    switch ($blog['type']){
                        case 2:
                            $classType = 'type_image';
                            $titleType = 'Albums';
                            break;
                        case 3:
                            $classType = 'type_video';
                            $titleType = 'Video';
                            break;
                        default:
                            $classType = 'type_article';
                            $titleType = 'Bài viết';
                            break;
                    }
        ?>
            <tr class="gradeX"> 
                <td><?php echo $blog['title']; ?></td>
                <td class="center"><?php echo $arrCategoryName[$blog['category_id']]; ?></td>
                <td class="center"><?php echo strftime('%d/%m/%Y - %H:%I', $blog['created_on']); ?></td> 
                <td class="center <?php echo $classType; ?>" title="<?php echo $titleType; ?>"><span style="position: absolute; left:-1000px"><?php echo $blog['type']; ?></span></td>
                <td class="center <?php echo ($blog['comments_enabled'])?'active':'inactive'; ?>"><span style="position: absolute; left:-1000px"><?php echo $blog['comments_enabled']; ?></span></td>
                <td class="center <?php echo ($blog['status'])?'active':'inactive'; ?>"><span style="position: absolute; left:-1000px"><?php echo $blog['status']; ?></span></td>
                <td class="center">
                    <a href="<?php echo base_url().'backend/blog/update/id/'.$blog['id']; ?>" title="Chỉnh sửa">
                        <img src="/static/backend/images/icons/fam/pencil.png"/>
                    </a>&nbsp;&nbsp;&nbsp;
                    <a class="delete_object" href="<?php echo base_url().'backend/blog/delete/id/'.$blog['id']; ?>" title="Xóa">
                        <img src="/static/backend/images/icons/fam/cancel.png"/>
                    </a>
                </td> 
            </tr>
        <?php
                }
            }
        ?>
        </tbody> 
    </table>
</div>
<div id="delete-confirm" title="Thông Báo" style="display: none; height: auto;">
    <p style="text-align: center;">Bạn có muốn xóa bài viết này không?</p>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>static/backend/js/DataTables/jquery.dataTables.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        // DataTables Config (more info can be found at http://www.datatables.net/)
        var oTable = $('.table').dataTable({
            "bJQueryUI": true,
            "aaSorting": [[2,'desc']],
            "bAutoWidth": true,
            "sScrollY": "100%",	
            "sScrollX": "100%",
            "sPaginationType": "full_numbers",
            "iDisplayLength": 50
        } );
        
        //Del click
        $('.mytable .delete_object').click(function(){
            var $del = $(this);
            $("#delete-confirm").dialog({
                buttons: {
                    "Yes": function() {
                        $(this).dialog("close");
                        window.location = $del.attr('href');
                    },
                    Cancel: function() {
                        $(this).dialog("close");
                    }
                }
            });
            return false;
        });
    });
</script>